{extends file="./main.tpl"}
{block name=head}
<style type="text/css" title="currentStyle">
  @import "./media/css/demo_page.css";
  @import "./media/css/demo_table_jui.css";
  @import "./media/css/jquery-ui-1.8.4.custom.css";
</style>
<script type="text/javascript" language="javascript" src="./media/js/jquery.js"></script>
<script type="text/javascript" language="javascript" src="./media/js/jquery.dataTables.js"></script>
<script type="text/javascript" charset="utf-8">
  $(document).ready(function() 
  {
	  oTable = $('#example').dataTable(
	  {
		  "bJQueryUI": true,
		  "sPaginationType": "full_numbers",
		  "aLengthMenu": [[10, 25, 50, 100, -1], [10, 25, 50, 100, "All"]],
		  "bPaginate": true,
	    "bAutoWidth": true,
	    "bScrollCollapse": true,
	    "bLengthChange": true,
	  });
  });
</script>
<script type="text/javascript" charset="utf-8">
	</script>
<script type="text/javascript">
$(document).ready(function() {
	$(".add").blur(function()
	{
	  if($(".add:last").val() != '' && $(".add:last").val() > 0)
	  {
      $("#one").clone(true).appendTo("#mainDiv")
      .find('input[type="text"]').val('').end()
      .find('select[option=""]').val('');
    }
    $('.amount:Last').val(0);
  });
});
function setTotalWeight()
{
  var totalWeight  = 0;
  
  $('.weight').each(function(i)
  {
    weight = $(this).val();
    if(!isNaN(weight))
    {
    	totalWeight += Number(weight);
    	$('#totalWeight').val(totalWeight);
    }
  }); 
}

function setTotalAmount()
{
  var totalAmount = 0;
  
  $('.amount').each(function(i)
  {
    amount = $(this).val();
    if(!isNaN(amount))
    {
    	totalAmount += Number(amount);
    	$('#totalAmount').val(totalAmount);
    }
  }); 
}

function myFunction()
{
  if(confirm("You Want To Remove This Record")== true)
	{
		return true;
	}
	else
	{
		return false;
	}
}

function disable()
{
  $('#btn').show();
  $('#submitBtn').hide();
}
</script>
{/block}
{block name=body}
<form name="driver" id="myform" action="{$smarty.server.PHP_SELF}" method="post">
<table align="center" border="2" cellpadding="2" cellspacing="2" width="" >
<tr>
  <td align="center" class="table1" colspan="16"><b>Loading Invoice</b></td>
</tr>
<tr>
  <td align="center" class="table2">FROM</td>
  <td align="center" class="table2">
    <input type="text" name="from" id="from" value="{$branchNameSelected}" READONLY >
    <input type="hidden" name="branchIdSelected" value="{$branchIdSelected}" >
  </td>
  <td align="center" class="table2">TO</td>
  <td align="center" class="table2">
  	<option value="0"></option>
  		<select name="toId" autofocus>
        {html_options values=$branchArray.branchId output=$branchArray.branchName}
      </select>
  </td>
  <td class="table2"  align="center" colspan="3">Truck No
    <select name="truckId" id="truckNo" required />
      <option value="">Select Truck No</option>
	    {html_options values=$truckDataArray.truckId output=$truckDataArray.truckNo}
	  </select>
  </td>
  <td class="table2"  align="center" colspan="2">Invoice No:<input type="text" name="invoiceNo" ></td>
  <td class="table2"  align="center" NoWRAP colspan="2">Invoice Date:
  {html_select_date prefix="invDate" field_order="DMY" day_value_format="%02d" month_format="%m" start_year ="-0" end_year="+2"}</td>
</tr>
<tbody  id="mainDiv">
<tr>
	<td class="table2"  align="center">&nbsp;</td>
	<td class="table2"  align="center">LR no.</td>
	<td class="table2"  align="center">LR Date.</td>
	<td class="table2"  align="center">Article / Qty</td>
	<td class="table2"  align="center">Description</td>
	<td class="table2"  align="center">Consignor</td>
	<td class="table2"  align="center">Consignee</td>
	<td class="table2"  align="center">Weight</td>
	<td class="table2"  align="center">To pay/ paid</td>
	<td class="table2"  align="center">Amount</td>
	<td class="table2"  align="center">Remarks</td>
</tr>
<tr id="one">
	 <td class="table2">
  	<select name="billType[]">
  	  {html_options values=$printValueArray output=$printOutputArray}
    </Select>
  </td>
	<td class="table2" align="center"><input type="text" name="lrNo[]" class="add" size="4"></td>
	<td class="table2" align="center" NoWRAP>
		{html_select_date field_array="lrDate[]" prefix="" start_year ="-0" end_year="+2" field_order ="DMY" month_format="%m" day_value_format="%02d"}</td>
	<td class="table2" align="center"><input type="text" name="qty[]" size="4"></td>
	<td class="table2" align="center">
    <select name="discriptionPartyDetailId[]" id="combo" >
    <option value="0">select</option>
      {html_options values=$itemArray.partyDetailId output=$itemArray.item}
    </select>
	  <input type="text" name="discription[]" id="tb">
	</td>
	<td class="table2" align="center">
    <select name="consignorPartyId[]">
    <option value="0">select</option>
      {html_options values=$PartyArray.partyId output=$PartyArray.name}
    </select>	
		<input type="text" name="consignor[]" >
	</td>
	<td class="table2" align="center"><input type="text" name="consignee[]" ></td>
	<td class="table2" align="center"><input type="text" name="weight[]" size="4" class="weight" onblur="setTotalWeight();"></td>
	<td class="table2" align="center">
	  <select name="toPay[]">
	    {html_options values=$topayValueArray output=$topayOutputArray}
	  <select>
  </td>
	<td class="table2" align="center"><input type="text" name="amount" class="amount" name="amount[]" onblur="setTotalAmount();" size="4" value="0"></td>
	<td class="table2" align="center"><textarea   name="remarks[]" cols="10" rows="2"></textarea></td>
</tr>
</tbody>
<tr>
  <td colspan="7" class="table2">&nbsp;</td>
  <td class="table2" align="center"><input type="text" id="totalWeight" name="totalWeight" size="4"></td>
  <td class="table2">&nbsp;</td>
  <td class="table2" align="center"><input type="text" id="totalAmount" name="totalAmount" size="4"></td>
  <td colspan="3" class="table2">&nbsp;</td>
</tr>
<tr>
  <td class="table1" align="center" colspan="12">
    <input type="submit" id="submitBtn" name="submit" value="Submit" onclick="fun();" class="button">
    <input type="button" id="btn" name="btn" value="Submit" class="button" style="display:none;">
  </td> 
</tr>
</table>
</form>
<br><br>
<body id="dt_example">
	<div id="container">
  <div class="demo_jui">
	  <table cellpadding="0" cellspacing="0" border="0" class="display" id="example">
		  <thead>
			  <tr>
				  <th NOWRAP><b>&nbsp;</b></th>
				  <th NOWRAP><b>&nbsp;</b></th>
				  <th NOWRAP><b>&nbsp;</b></th>
				  <th NOWRAP><b>FROM</b></th>
				  <th NOWRAP><b>TO</b></th>
				  <th NOWRAP><b>Truck No</b></th>
				  <th NOWRAP><b>Invoice No</b></th>
				  <th NOWRAP><b>Total Weight</b></th>
				  <th NOWRAP><b>Invoice Date</b></th>
				</tr>
			</thead>
			<tbody>
			  {section name="sec" loop=$loadingArray}
				  <tr>
				    <td class="table2" align="center"><a href="loadingInvoiceAdd.php?loadingInvoiceId={$loadingArray[sec].loadingInvoiceId}" class="link" style="color: red;"> Add</a></td>      
				    <td class="table2" align="center"><a href="loadingDetail.php?loadingInvoiceId={$loadingArray[sec].loadingInvoiceId}" class="link" style="color: red;">Detail</a></td>      
				    <td class="table2" align="center"><a href="loadingDelete.php?loadingInvoiceId={$loadingArray[sec].loadingInvoiceId}" onclick="return myFunction();" class="link"> <img src="./images/deleteIco.png"></a></td>
				    <td class="table2" align="center">{$loadingArray[sec].fromName}</td>
				    <td class="table2" align="center">{$loadingArray[sec].toName}</td>
				    <td class="table2" align="center">{$loadingArray[sec].truckNo}</td>
				    <td class="table2" align="center">{$loadingArray[sec].invoiceNo}</td>
				    <td class="table2" align="center">{$loadingArray[sec].totalWeight}</td>
				    <td class="table2" align="center">{$loadingArray[sec].invoiceDate}</td>
				  </tr>
				  {/section}
			</tbody>
		</table>
	</div>
	<div class="spacer"></div>
	</div>
</body>

{/block}
